package com.liuliuliu.payment.globalpaymentspringbootstarter.service.impl;

import com.alibaba.fastjson.JSON;
import com.liuliuliu.payment.globalpaymentspringbootstarter.enums.PaymentChannelEnum;
import com.liuliuliu.payment.globalpaymentspringbootstarter.request.GetPaymentLinkReq;
import com.liuliuliu.payment.globalpaymentspringbootstarter.request.base.CommonPaymentReq;
import com.liuliuliu.payment.globalpaymentspringbootstarter.request.commerce.CommerceAccountInfo;
import com.liuliuliu.payment.globalpaymentspringbootstarter.response.GenPaymentLinkResp;
import com.liuliuliu.payment.globalpaymentspringbootstarter.service.PaymentService;

import java.util.logging.Logger;

public class CommercePaymentService implements PaymentService {

    private static Logger log = Logger.getLogger(CommercePaymentService.class.getName());

    @Override
    public PaymentChannelEnum getPaymentChannel() {
        return PaymentChannelEnum.COMMERCE;
    }

    @Override
    public GenPaymentLinkResp genPaymentUrl(GetPaymentLinkReq req) {
        CommonPaymentReq commonPaymentReq = JSON.parseObject(JSON.toJSONString(req.getParams()), CommonPaymentReq.class);

        CommerceAccountInfo commerceAccountInfo = JSON.parseObject(JSON.toJSONString(req.getAccountInfo()), CommerceAccountInfo.class);

        log.info("gen commerce payment link");

        log.info("commerce payment req param:" + JSON.toJSONString(commonPaymentReq));
        return null;
    }

}
